'use strict';
// Copyright 2014 Blueant Inc. All Rights Reserved.

/**
 * @fileoverview 副本星星奖励
 * @author sundbcn@gmail.com (sun debing)
 */

var moment = require('moment');
var _ = require('lodash');
var mongoose = require('mongoose');

var starItemSchema = new mongoose.Schema({
    // 副本章节
    copy_chapter: {
        type: Number,
        require: true
    },

    // 领取奖励列表
    reward_list: [Number]
});

starItemSchema.methods.addRewardList = function (position) {
    if (!this.isHaveReceive(position)) {
        return false;
    }
    this.reward_list.push(position);
    return true;
};

starItemSchema.methods.getCopyChapter = function () {
    return this.copy_chapter;
};

starItemSchema.methods.isHaveReceive = function (position) {
    if (_.indexOf(this.reward_list, position) !== -1) {
        return false;
    }
    return true;
};

if (!starItemSchema.options.toJSON) {
    starItemSchema.options.toJSON = {};
}
/* jshint unused:false */
starItemSchema.options.toJSON.transform = function (doc, ret) {
    delete ret.pass_time;
};

module.exports = starItemSchema;
